<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    
<%@ page import="com.javapig.util.*"%>
<%@ page import="com.dd.exception.*" %>
<%@ page import="java.util.*" %>
<%@ page import="com.dd.*" %>
<%@ page import="java.util.ArrayList" %>

<%@ include file="global.jsp" %>
<%@ include file="header.jsp" %>

<%
	boolean deleteError = false;
	int deleteUserID = ParamUtils.getIntParameter(request, "deleteid", -1);
	//删除用户
	if(deleteUserID != -1)
	{
		try
		{
			UserManager uManager = new UserManager();
			User ux = uManager.getUser(deleteUserID);
			if(ux != null)
			{
				uManager.deleteUser(ux);
			}
		}
		catch(Exception ex)
		{
			deleteError = true;
		}

	}
	ArrayList caiGouYuans = UserManager.GetAllCaiGouUsers();
	int nCaiGouCount = caiGouYuans.size();
	
	ArrayList shenHeYuans = UserManager.GetAllShenHeusers();
	int nShenHeCount = shenHeYuans.size();
%>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<p>

<%

    String title = "用户信息概览";
    String[][] breadcrumbs = {
        {"主页面", "main.jsp"},
        {title, "createUser.jsp"}
    };
    StringBuffer pageGuide = new StringBuffer();
    for (int i=0; i<breadcrumbs.length; i++){
      for(int j=0; j<breadcrumbs[i].length; j++){
          pageGuide.append(breadcrumbs[i][j]+"@");
      }
    }
  

%>

<jsp:include page="title.jsp" flush="true">
   <jsp:param name="title" value="<%=title%>" />
   <jsp:param name="pageGuide" value="<%=pageGuide%>" />
</jsp:include>
	
	<%
		if(deleteError)
		{
	%>
		<span id="errorInfo" style="color:Red;">删除用户时发生错误!!</span>
	
	<% } %>

	<p/>
	<h3>所有采购人员信息:<h3>
	<table width="95%" border="0" cellpadding="1" cellspacing="1" bgcolor="<%= tblBorderColor %>" frame="box">
		<tr bgcolor="#eeeeee" align="center">
			<th width="21%">登录名</th>
			<th width="19%">姓名</th>
			<th width="51%">所属项目</th>
			<th width="9%">删除</th>
		</tr>	
		<%
			if(nCaiGouCount>0)
			{
	     	 	Iterator it = caiGouYuans.iterator();
        	 	while(it.hasNext())
        	 	{
        	 		User ux = (User)it.next();
        	 		if(ux != null)
        	 		{
        	 			ArrayList xms = XiangMuManager.GetUserManageedXiangMuByUserID(ux.getId());
        	 			//采购员有且尽有一个项目
        	 			XiangMu xm = (XiangMu)(xms.get(0));
        	 			
		%>
		<tr bgcolor="#ffffff">
			<td><%=ux.getYongHuMing() %></td>
			<td><%=ux.getXingMing() %></td>
			<td><%=xm.getMingCheng() %></td>
			<td align="center" onclick="return   confirm('您真的要删除该用户吗？');">
				<a href="UserGeneralInfo.jsp?deleteid=<%=ux.getId()%>">
					<img src="images/button_delete.gif" width="17" height="17" alt="删除..." border="0" />
				</a>
			</td>
	  
		</tr>
		<%
        	 		}
        	 	}
			}
		%>
</table>
	<p/>
	
	<h3>所有审批人员信息:</h3>
		<table width="95%" border="0" cellpadding="1" cellspacing="1" bgcolor="<%= tblBorderColor %>">
		<tr bgcolor="#eeeeee">
			<th width="21%">登录名</th>
			<th width="19%">姓名</th>
			<th width="28%">所属部门</th>
			<th width="23%">管理的项目</th>
			<th width="9%">删除</th>
		</tr>
		<%
			if(nShenHeCount>0)
			{
	     	 	Iterator it = shenHeYuans.iterator();
        	 	while(it.hasNext())
        	 	{
        	 		User ux = (User)it.next();
        	 		if(ux != null)
        	 		{
        	 			ArrayList xms = XiangMuManager.GetUserManageedXiangMuByUserID(ux.getId());
        	 			//审核人员管理多个项目
        	 			int nuserXMsCount = xms.size();
        	 			
        	 			BuMenInfo bm = BuMenManager.GetUserBuMenInfoByUserID(ux.getId());
        	 			
		%>
		<tr bgcolor="#ffffff">
			<td><%=ux.getYongHuMing() %></td>
			<td><%=ux.getXingMing() %></td>
			<td><%=bm.getBuMenMingCheng() %></td>
			<td>
					<%
						if(nuserXMsCount >0 )
						{
							Iterator itxm = xms.iterator();
							while(itxm.hasNext())
							{
								XiangMu xmUx = (XiangMu)itxm.next();
								
					%>
				   				 <li><%=xmUx.getMingCheng() %></li>
				    <%
							}
						}
				    %>
			</td>
			<td align="center" onclick="return   confirm('您真的要删除该用户吗？');">
				<a href="UserGeneralInfo.jsp?deleteid=<%=ux.getId()%>">
					<img src="images/button_delete.gif" width="17" height="17" alt="删除..." border="0" />
				</a>
			</td>
	  
		</tr>
		<%
        	 		}
        	 	}
			}
		%>
</table>
</body>
</html>